/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package OLDSTUFF.ClassAlgebra;

import OLDSTUFF.HierarchyPackage.HClass;
import OLDSTUFF.HierarchyPackage.HierarchyException;

/**
 *
 * @author Martin Haulrich
 */
public class SimpleExpression implements Expression {

    public final static int type = Expression.SIMPLE;

    public final HClass c;

    public final int hash;

    public SimpleExpression(HClass c) {
        
            this.c = c;
      
            hash = 11 * c.hashCode();
        
    }


    @Override
    public int type() {
        return type;
    }


    @Override
    public String toString() {
        try {
            return c.getName();
        } catch (HierarchyException ex) {
            
            return "";
        }
    }
    
     @Override
    public boolean equals(Object o) {
        
        if (o instanceof SimpleExpression) {
            SimpleExpression se = (SimpleExpression) o;
   //         System.err.println("SimExp: " + c + " : " + se.c + "  " + c.equals(se.c));
            return (c.equals(se.c));
        }
        return false;
    }


    @Override
    public int hashCode() {
        
        return hash;
    }
     
     
 
}
